home *** CD-ROM | disk | FTP | other *** search
- #include "bbs.h"
- #include <dos.h>
- /*
- struct AEInfo {
- struct MsgPort *WriteSerPort;
- struct MsgPort *ReadSerPort;
- struct MsgPort *WriteConPort;
- struct MsgPort *ReadConPort;
- struct MsgPort *TimerPort;
- struct MsgPort *MyRexxPort;
- struct MsgPort *StatWritePort;
- struct MsgPort *ZmodemWritePort;
- struct IOStdReq *StatWriteReq;
- struct IOStdReq *ZmodemWriteReq;
- struct IOExtSer *WriteSerReq,*ReadSerReq;
- struct IOStdReq *WriteConReq,*ReadConReq;
- struct Commands *Cmds;
- UBYTE SOUT;
- UBYTE COUT;
- };*/
- void getsystime(long number,char *d,char *t);
- int strwild(char *str,char *str1,char wild,int len)
- {
- int i=0;
- if(*(str+i)=='\0' || len==0) return(1);
- while(*(str+i) && i<len)
- {
- if(*(str1+i)=='\0') return(1);
- if(*(str1+i)==wild ) { i++; continue; }
- if(*(str+i)!=*(str1+i)) return(1);
- i++;
- }
- return(0);
- }
-
- void strlim(char *str1,char *str2,int limit)
- {
- int i=0;
- int tlimit=0;
- while(*(str2+tlimit)!='\0') tlimit++;
- if(limit==-1) limit=tlimit;
- while(i<limit)
- {
- if(i<tlimit)
- *(str1+i)=*(str2+i);
- else *(str1+i)=' ';
- i++;
- }
- *(str1+i)='\0';
- }
-
- #define addansi p=0; ansi->buf[ansi->ansicode]='\0'; while(ansi->buf[p]!='\0') \
- { *(d+k)=ansi->buf[p]; k++; p++; }
-
- void stripansi(char *s,char *d,struct ansi *ansi,int resetit,int strip)
- {
- // static int ansicode=0;
- // static char anrbuf[20];
- register int i,j,k,p;
- if(resetit) { ansi->ansicode=0; return; }
- i=strlen(s);j=k=0;
- while(j<i)
- {
- if(*(s+j)=='\r' && strip) { j++; ansi->ansicode=0; continue;}
- if(!ansi->ansicode && *(s+j)!='') { *(d+k)=*(s+j); j++; k++; continue; }
- else
- {
- if(ansi->ansicode)
- {
- ansi->buf[ansi->ansicode]=*(s+j);
- if(ansi->ansicode==1 && *(s+j)!='[')
- {
- ansi->ansicode++; addansi ansi->ansicode=0;
- }
- else
- {
- switch(*(s+j))
- {
- case 'm': ansi->ansicode=0; break;
- default: ansi->ansicode++; if((*(s+j)>='A' && *(s+j)<='Z') ||
- (*(s+j)>='a' && *(s+j)<='z'))
- {
- addansi ansi->ansicode=0;
- } break;
- }
- }
- }
- else if(*(s+j)=='') { ansi->buf[0]=''; ansi->ansicode=1; }
- }
- j++;
- }
- *(d+k)='\0';
- }
- STRPTR GetTheDate(long number)
- {
- char Date[22];
- getsystime(number,Date,NULL);
- return(Date);
- }
- STRPTR GetTheTime(long number)
- {
- char temp[30];
- getsystime(number,NULL,temp);
- return(temp);
- }
-
- void ConPutStr(char *s)
- {
- if(KEYIN)
- {
- WriteConReq->io_Data = (APTR)s;
- WriteConReq->io_Length = strlen(s);
- DoIO(WriteConReq);
- }
- }
- void SerPutStr(unsigned char *string)
- {
- if(SEROUT)
- {
- WriteSerReq->IOSer.io_Data = (APTR)string;
- WriteSerReq->IOSer.io_Length = strlen(string);
- DoIO((struct IORequest *)WriteSerReq);
- }
- }
- void ConPutChar(char *ch)
- {
- if(KEYIN)
- {
- WriteConReq->io_Data = (APTR)ch;
- WriteConReq->io_Length = 1;
- DoIO(WriteConReq);
- }
- }
- void SerPutChar(char *ch)
- {
- if(SEROUT)
- {
- WriteSerReq->IOSer.io_Data = (APTR)ch;
- WriteSerReq->IOSer.io_Length = 1;
- DoIO((struct IORequest *)WriteSerReq);
- }
- }
-
- int CheckCon(void)
- {
- if(KEYIN) return((int)CheckIO(ReadConReq));
- return(0);
- }
- int CheckSer(void)
- {
- if(SEROUT) return((int)CheckIO((struct IORequest *)ReadSerReq));
- return(0);
- }
-
- int SCheckInput(void)
- {
- int result1=0,result2=0;
- if(KEYIN) result1=CheckIO(ReadConReq);
- if(SEROUT) result2=CheckIO((struct IORequest *)ReadSerReq);
- return(result1||result2);
- }
-
- void ConPutBlk(char *s,int length)
- {
- if(KEYIN){
- WriteConReq->io_Data = (APTR)s;
- WriteConReq->io_Length = length;
- DoIO(WriteConReq);
- }
- }
- void SerPutBlk(char *s,int length)
- {
- if(SEROUT){
- WriteSerReq->IOSer.io_Data = (APTR)s;
- WriteSerReq->IOSer.io_Length = length;
- DoIO((struct IORequest *)WriteSerReq);
- }
- }
-
- BYTE CheckForNS(char *s)
- {
- char chr;
-
- if(strlen(s)>1) {
- chr=s[strlen(s)-2];
- if(chr=='N'||chr=='n') {
- chr=s[strlen(s)-1];
- if(chr=='S'||chr=='s') {
- return(1);
- }
- }
- }
- return(0);
- }
- int CheckForAst(char *s)
- {
- int i;
- for(i=0; i<strlen(s); i++) {
- if(s[i]=='*' && GET_BIT(ACS_WILDCARDS)) return(i+1);
- }
- return(FALSE);
- }
- int GetUN(char *SA)
- {
- int x,N=0;
-
- x=0;
- while(*(SA+x)!='\0')
- {
- if(*(SA+x)=='@')
- {
- N=1; *(SA+x)='\0';x++;
- break;
- }
- x++;
- }
- if(N) return(atoi((APTR)(SA+x)));
- return(0);
- }
- int CompareTheseTwo(char *str,char *str2)
- {
- if(str[0]==str2[0])
- {
- if(str[1]==str2[1])
- {
- if(str[2]==str2[2])
- {
- return(SUCCESS);
- }
- }
- }
- return(FAILURE);
- }
- void StripReturn(char *str)
- {
- register i;
- i=strlen(str)-1;
- while(i>0)
- {
- if(*(str+i)<=32) *(str+i)='\0'; else return;
- i -=1;
- }
- }
- int ProcessLine(char *pat,char *vorig,char *dest)
- {
- int i,i2,nff;
- char rep[80],orig[100];
-
- strcpy(orig,vorig);
- for(i=0; i<=strlen(pat); i++) {
- if(pat[i]==';') break;
- }
-
- if(i>=strlen(pat)) return(0);
-
- pat[i]='\0';
- strcpy(rep,(char *)&pat[i+1]);
-
- dest[0]='\0';
-
- for(i=0; i<=(strlen(orig)-strlen(pat)); i++) {
- nff=1;
- if(pat[0]==orig[i]) {
- nff=0;
- for(i2=i+1; (i2-i)<strlen(pat); i2++) {
- if(pat[i2-i]!=orig[i2]) {
- nff=1;
- break;
- }
- }
- }
- if(nff!=1) {
- orig[i]='\0';
- strcpy(dest,orig);
- strcat(dest,rep);
- if(i2<strlen(vorig)) strcat(dest,(char *)&orig[i2]);
- dest[75]='\0';
- return(1);
- }
- }
- return(0);
- }
- int jive(char *nam, char *pat)
- {
- register char *p; /* Thu Jan 16 14:50:30 1992 */
-
- for (;;) {
- if (tolower(*nam) == tolower(*pat)) {
- if(*nam++ == '\0') return(SUCCESS);
- pat++;
- } else if (*pat == '?' && *nam != 0) {
- nam++;
- pat++;
- } else break;
- }
-
- if (*pat != '*') return(FAILURE);
- while (*pat == '*') {
- if (*++pat == '\0') return(SUCCESS);
- }
-
- for (p=nam+strlen(nam)-1;p>=nam;p--) {
- if (tolower(*p) == tolower(*pat))
- if (jive(p,pat) == SUCCESS) return(SUCCESS);
- }
- return(FAILURE);
- }
-
- /*
- * # seconds between 1-1-70 (Unix time base) and 1-1-78 (Amiga time base).
- * Add this value to the returned seconds count to convert Amiga system time
- * to normal Unix system time.
- */
-
- ULONG UnixTimeOffset = 252482400;
-
- /**********************************************************
- * ULONG getsystime(struct timeval *tv)
- *
- * This function was rewritten using DateStamp() to
- * eliminate the opening and closing of the timer.device
- * that was occurring everytime this function was called.
- * An attempt to save some processing time. -WMP-
- **********************************************************/
- void getsystime(long number,char *d,char *t)
- {
- struct DateStamp ds;
- struct DateTime dt;
- if(number==0L)
- {
- DateStamp(&ds);
- dt.dat_Stamp=ds;
- }
- else
- {
- number -= UnixTimeOffset;
- dt.dat_Stamp.ds_Days=number/(60L*60L*24L);
- number -= dt.dat_Stamp.ds_Days*(60L*60L*24L);
- dt.dat_Stamp.ds_Minute=number/60L;
- dt.dat_Stamp.ds_Tick=0L;
- }
- dt.dat_Format=FORMAT_USA;
- dt.dat_StrDay=NULL;
- dt.dat_StrDate=d;
- dt.dat_StrTime=t;
- dt.dat_Flags=DTB_SUBST;
- DateToStr(&dt);
- }
- void prbuf(char c);
-
- int mysprintf(char *buffer, char *ctl, ...)
- {
- long *arg1;
-
- arg1 = (long *) (&ctl + 1);
- RawDoFmt(ctl, (APTR)arg1, prbuf, (APTR)buffer);
- return((int)strlen (buffer));
- } /* End of int mysprintf() */
-
- /**********************************************************
- * void prbuf(char c)
- *
- * This stub routine is called from the RawDoFmt routine for
- * each character in the string. At invocation, we have:
- * D0 - next character to be formatted
- * A3 - pointer to data buffer
- **********************************************************/
- #define R_A3 (8 + 3)
-
- void prbuf(char c)
- {
- char *p = (char *) __builtin_getreg(R_A3);
- *p++ = c;
- __builtin_putreg(R_A3, (long) p);
- } /* End of void prbuf() */
-
-